package com.example.ch9;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.example.ch8.Dog;
import com.example.ch8.PersonDog;

public class SetServlet extends HttpServlet {

    /*
     * (non-Javadoc)
     * @see
     * javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest
     * , javax.servlet.http.HttpServletResponse)
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        PersonDog p = new PersonDog();
        p.setName("Dylan");
        p.setDog(new Dog("ww"));
        req.setAttribute("person", p);

        Map map = new HashMap();
        map.put("u1", "u1");
        map.put("u2", "u2");
        map.put("u3", "u3");
        req.setAttribute("map", map);

        RequestDispatcher dispatcher = req.getRequestDispatcher("set.jsp");
        dispatcher.forward(req, resp);
    }
}
